<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>用户登录</title>
<link rel="stylesheet" type="text/css" href="css/hui.css" />
</head>
<body>
<header class="hui-header"  style="margin-top:15px;">
    <div id="hui-back"></div>
    <h1>用户登录</h1>
</header>
<div class="hui-wrap">
    <div class="hui-center-title" style="margin-top:35px;"><h1>请先登录！</h1></div>
    <div style="margin:28px 15px; margin-bottom:15px;" class="hui-form" id="form1">
        <div class="hui-form-items">
            <input type="number" id="phone" class="hui-input hui-input-clear" placeholder="手机号码" checkType="phone" value="18100998888" checkMsg="请填写正确的手机号" />
        </div>
        <div class="hui-form-items">
            <input type="password" class="hui-input hui-pwd-eye" value="888888" placeholder="登录密码" checkType="string" id="pwd" checkData="6,20" checkMsg="密码应为6-20个字符" />
        </div>
    </div>
    <div style="padding:28px 15px; padding-top:0px;">
        <button type="button" class="hui-button hui-button-large hui-primary" id="submit">登 录</button>
        <div style="margin-top:18px;">
        	<div class="hui-fr">
        		<a href="javascript:hui.open('register.html');">新用户注册</a>
        	</div>
        </div>
    </div>
</div>
<script type="text/javascript" src="js/hui.js" charset="UTF-8"></script>
<script src="js/hui-form.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	hui.plusReady(function(){
hui.formInit();
hui('#submit').click(function(){
	if(hui('#submit').buttonIsLoading()){return false;}
    //验证
    var res = huiFormCheck('#form1');
    if(!res){return false;}
    //
    hui('#submit').loadingButton('提交中...');
    hui.postJSON(
    	'http://shop.hcoder.net/myApi.php',
		{act:"login", phone:hui('#phone').val(), pwd:hui('#pwd').val()},
		function(res){
			huiJsonLog(res);
			hui('#submit').resetLoadingButton();
			if(res.msg == 'ok'){
				hui.toast("登录成功");
				//记录客户信息到本地
				console.log(res.uid)
				plus.storage.setItem('SUID', res.uid);
				plus.storage.setItem('SNICKNAME', res.nickname);
				plus.storage.setItem('SRAND', res.randnum);
				plus.storage.setItem('SFACE', res.face);
				var _self = plus.webview.currentWebview();
				setTimeout(function(){
					var aas=hui.getItem('SUID')
				console.log(aas)
					_self.hide();}, 3000);
				
				return;
			}else if(res.msg == 'error'){
				hui.toast("账号或密码错误");
				return;
			}
			hui.toast("服务器忙，请重试");
			
		}
    );
});


})
</script>
</body>
</html>
